package com.hzhr.iot.device.controller;

import com.hzhr.iot.core.annotation.ApiImplicitInternalParams;
import com.hzhr.iot.core.annotation.Author;
import com.hzhr.iot.core.exception.ServiceException;
import com.hzhr.iot.device.controller.base.BaseController;
import com.hzhr.iot.device.model.collectData.CollectDataGetModel;
import com.hzhr.iot.device.model.collectData.CollectDataPostModel;
import com.hzhr.iot.device.service.CollectDataService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.Map;

@Api(tags = "CollectData", description = "采集数据")
@RestController
@RequestMapping(value = "")
public class CollectDataController extends BaseController {
    @Autowired
    CollectDataService collectDataService;

    //region /collect-datas POST
    //region swagger响应码 : post
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功"),
    })
    //endregion
    //region swagger说明 : post
    @ApiOperation(value="新增采集数据", notes="新增采集数据  \n简介 : 新增采集数据  \n步骤 :  \n1. 新增采集数据 : (√)  \n 根据body新增采集数据(COLLECT_DATA)collectData_1；  \n2. 返回信息 : (√)  \n 根据条件参数查询创建结果，组装响应并返回；  \n",produces = "application/json")
    //endregion
    //region swagger参数 : post
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "令牌",required = true, dataType = "string", paramType = "header"),

            @ApiImplicitParam(name = "show_total", value = "是否展示总数", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "show_info", value = "是否展示详情", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),

    })
    @ApiImplicitInternalParams({
            @ApiImplicitParam(name = "_token", value = "令牌",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-id", value = "用户编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-code", value = "用户代码",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-name", value = "用户名",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-company-id", value = "公司编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-dept-id", value = "部门编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-type", value = "用户类型(关联: common_service.options.code, typeCode = 'USER_TYPE')",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-id", value = "交易流水号",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-type", value = "交易类型",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-access-mode", value = "访问模式 0:一般 1:全局",defaultValue = "0", required = false, dataType = "int", paramType = "header"),

            @ApiImplicitParam(name = "_show_total", value = "是否展示总数", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "_show_info", value = "是否展示详情", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),

    })
    //endregion
    //region 请求 : post
    @RequestMapping(value = "/collect-datas", method = RequestMethod.POST)
    //endregion
    @Author
    public ResponseEntity<CollectDataGetModel> post(@RequestParam @ApiIgnore Map<String, Object> query,
                                                    @RequestBody CollectDataPostModel body) throws ServiceException {
        CollectDataGetModel responseBody = collectDataService.post(initHeader(), query, body);
        return new ResponseEntity<>(responseBody, HttpStatus.OK);
        //endregion
    }
    //endregion
    //region /collect-datas GET
    //region swagger响应码 : get
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功"),
    })
    //endregion
    //region swagger说明 : get
    @ApiOperation(value="查询采集数据", notes="查询采集数据  \n简介 : 查询采集数据  \n步骤 :  \n1. 查询采集数据 : (√)  \n 查询采集数据(COLLECT_DATA)；  \n2. 返回信息 : (√)  \n 根据条件参数和查询到的结果组装响应并返回；  \n",produces = "application/json")
    //endregion
    //region swagger参数 : get
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "令牌",required = true, dataType = "string", paramType = "header"),

            @ApiImplicitParam(name = "show", value = "展示形式 one:展示一个,list:展示列表,null(空值):不展示", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "show_total", value = "是否展示总数", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "show_info", value = "是否展示详情", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "show_collectDevice", value = "是否展示采集设备信息", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "show_ext", value = "是否展示额外信息", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "page", value = "页数", defaultValue = "1",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "count", value = "每页数量", defaultValue = "1",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "equal_id", value = "筛选条件 : where collectData.id = #{equal_id}",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "equal_collectDeviceId", value = "筛选条件 : where collectData.collectDeviceId = #{equal_collectDeviceId}",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "equal_collectDeviceCode", value = "筛选条件 : where collectData.collectDeviceCode = #{equal_collectDeviceCode}",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "equal_currentTm", value = "筛选条件 : where collectData.currentTm = #{equal_currentTm}",required = false, dataType = "long", paramType = "query"),
            @ApiImplicitParam(name = "greaterthanorequal_currentTm", value = "筛选条件 : where collectData.currentTm >= #{greaterthanorequal_currentTm}",required = false, dataType = "long", paramType = "query"),
            @ApiImplicitParam(name = "greaterthan_currentTm", value = "筛选条件 : where collectData.currentTm > #{greaterthan_currentTm}",required = false, dataType = "long", paramType = "query"),
            @ApiImplicitParam(name = "lessthanorequal_currentTm", value = "筛选条件 : where collectData.currentTm <= #{lessthanorequal_currentTm}",required = false, dataType = "long", paramType = "query"),
            @ApiImplicitParam(name = "lessthan_currentTm", value = "筛选条件 : where collectData.currentTm < #{lessthan_currentTm}",required = false, dataType = "long", paramType = "query"),
            @ApiImplicitParam(name = "orderBy_currentTm", value = "筛选条件 : order by collectData.currentTm #{orderBy_currentTm}",required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "equal_iotDeviceId", value = "筛选条件 : where collectData.iotDeviceId = #{equal_iotDeviceId}",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "isnull_alarmCodes", value = "筛选条件 : where collectData.alarmCodes is (not) null",required = false, dataType = "boolean", paramType = "query"),

    })
    @ApiImplicitInternalParams({
            @ApiImplicitParam(name = "_token", value = "令牌",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-id", value = "用户编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-code", value = "用户代码",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-name", value = "用户名",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-company-id", value = "公司编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-dept-id", value = "部门编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-type", value = "用户类型(关联: common_service.options.code, typeCode = 'USER_TYPE')",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-id", value = "交易流水号",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-type", value = "交易类型",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-access-mode", value = "访问模式 0:一般 1:全局",defaultValue = "0", required = false, dataType = "int", paramType = "header"),

            @ApiImplicitParam(name = "_show", value = "展示形式 one:展示一个,list:展示列表,null(空值):不展示", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "_show_total", value = "是否展示总数", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "_show_info", value = "是否展示详情", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "_show_collectDevice", value = "是否展示采集设备信息", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "_show_ext", value = "是否展示额外信息", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "_page", value = "页数", defaultValue = "1",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "_count", value = "每页数量", defaultValue = "1",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "_equal_id", value = "筛选条件 : where collectData.id = #{_equal_id}",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "_equal_collectDeviceId", value = "筛选条件 : where collectData.collectDeviceId = #{_equal_collectDeviceId}",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "_equal_collectDeviceCode", value = "筛选条件 : where collectData.collectDeviceCode = #{_equal_collectDeviceCode}",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "_equal_currentTm", value = "筛选条件 : where collectData.currentTm = #{_equal_currentTm}",required = false, dataType = "long", paramType = "query"),
            @ApiImplicitParam(name = "_greaterthanorequal_currentTm", value = "筛选条件 : where collectData.currentTm >= #{_greaterthanorequal_currentTm}",required = false, dataType = "long", paramType = "query"),
            @ApiImplicitParam(name = "_greaterthan_currentTm", value = "筛选条件 : where collectData.currentTm > #{_greaterthan_currentTm}",required = false, dataType = "long", paramType = "query"),
            @ApiImplicitParam(name = "_lessthanorequal_currentTm", value = "筛选条件 : where collectData.currentTm <= #{_lessthanorequal_currentTm}",required = false, dataType = "long", paramType = "query"),
            @ApiImplicitParam(name = "_lessthan_currentTm", value = "筛选条件 : where collectData.currentTm < #{_lessthan_currentTm}",required = false, dataType = "long", paramType = "query"),
            @ApiImplicitParam(name = "_orderBy_currentTm", value = "筛选条件 : order by collectData.currentTm #{_orderBy_currentTm}",required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "_equal_iotDeviceId", value = "筛选条件 : where collectData.iotDeviceId = #{_equal_iotDeviceId}",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "_isnull_alarmCodes", value = "筛选条件 : where collectData.alarmCodes is (not) null",required = false, dataType = "boolean", paramType = "query"),

    })
    //endregion
    //region 请求 : get
    @RequestMapping(value = "/collect-datas", method = RequestMethod.GET)
    //endregion
    @Author
    public ResponseEntity<CollectDataGetModel> get(@RequestParam @ApiIgnore Map<String, Object> query) throws ServiceException {
        CollectDataGetModel responseBody = collectDataService.get(initHeader(), query);
        return new ResponseEntity<>(responseBody, HttpStatus.OK);
        //endregion
    }
    //endregion
}

















































































































































































































































































































































































































































































































































































































































































